<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<div class="row" style="padding:2px">
	<div class="col-sm-12 col-md-12 col-lg-12">
		<div class="form-group">
			<a id="ajax_design_btn_add" class="btn btn-default " data-toggle="modal"><i class="fa fa-lg fa-plus"></i> 初步设计登记表</a>
			<a id="ajax_design_btn_all" class="btn btn-default pull-right "><i class="fa fa-lg fa-refresh"></i>显示所有项目</a>
		</div>
	</div>
</div>
<!-- rows -->
<!-- widget grid -->
<section id="widget-grid" class="">

	<!-- row -->
	<div class="row">
		<input id="keyId" name="keyId" hidden value="<s:property value="keyId"></s:property> "/>
		<!-- NEW WIDGET Reply -->
		<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget " id="wid-id-0" data-widget-editbutton="false"
				 data-widget-colorbutton="false"
				 data-widget-togglebutton="false"
				 data-widget-deletebutton="false"
				 data-widget-fullscreenbutton="true"
				 data-widget-custombutton="false"
				 data-widget-sortable="false">

				<header>
					<span class="widget-icon"> <i class="fa fa-table"></i> </span>
					<h2>初步设计登记表</h2>
				</header>

				<!-- widget div-->
				<div>

					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->

					</div>
					<!-- end widget edit box -->

					<!-- widget content -->
					<div class="widget-body no-padding">
						<div class="col-sm-12 col-md-12 col-lg-12">
							<div class=" ">
								<div class="row" id="ajax_design_list_row">
									<table id="ajax_design_table" class="table table-striped table-bordered table-hover">
									</table>
									<div id="ajax_design_list_page">
									</div>
								</div>

							</div>
						</div>

					</div>
					<!-- end widget content -->

				</div>
				<!-- end widget div -->

			</div>
			<!-- end widget -->

		</article>
		<!-- WIDGET END -->

	</div>

	<!-- end row -->

	<!-- end row -->

</section>
<!-- end widget grid -->



<script type="text/javascript">
	// DO NOT REMOVE : GLOBAL FUNCTIONS!
	pageSetUp();

	function reload(){
		loadURL("ajax!design.action",$('#content'));
	}

</script>

<script type="text/javascript">
	$(function(){
		load_design_jqGrid();
	});
	function load_design_jqGrid(){
		jQuery("#ajax_design_table").jqGrid({
			url:'ajax-design!list.action?keyId='+$("input#keyId").val(),
			datatype: "json",
			colNames:['项目名称 ',"批复日期 ",'批复概算金额','文档状态',"归档日期","操作","id"],
			colModel:[
				{name:'name',index:'name', width:30,sortable:false},
				{name:'replyDate',index:'replyDate', width:70},
				{name:'replyMoney',index:'replyMoney', width:70},
				{name:'processState',index:'processState', width:120,sortable:false},
				{name:'overDate',index:'overDate', width:110,sortable:false},
				{name:'act',index:'act', width:150,sortable:false,fixed:true},
				{name:'id',index:'id', width:50,hidden:true}
			],
			rowNum : 10,
			rowList:[10,20,30],
			pager : '#ajax_design_list_page',
			sortname : 'id',
			sortorder : "asc",
			gridComplete:function(){
				var ids=$("#ajax_design_table").jqGrid('getDataIDs');
				for(var i=0;i<ids.length;i++){
					var cl=ids[i];
					de="<button class='btn btn-default' data-original-title='查看' onclick=\"fn_design_read('"+cl+"');\"><i class='fa fa-eye'></i>查看</button>"+" ";
					jQuery("#ajax_design_table").jqGrid('setRowData',ids[i],{act:de});
				}
				$(".ui-jqgrid-bdiv").css("overflow-x","hidden");
				jqGridStyle();
			},
			jsonReader: {
				root: "dataRows",
				page: "page",
				total: "total",
				records: "records",
				repeatitems : false
			},
			multiselect : false,
			rownumbers:true,
			gridview:true,
			shrinkToFit:true,
			viewrecords: true,
			autowidth: true,
			height:'auto',
			forceFit:true,
			loadComplete: function() {
			}
		});
		$(window).on('resize.jqGrid', function() {
			jQuery("#ajax_design_table").jqGrid('setGridWidth', $("#ajax_design_list_row").width());
		})

		jQuery("#ajax_design_table").jqGrid('navGrid', "#ajax_design_list_page", {
			edit : false,
			add : false,
			del : false,
			search:false
		});
	};

	$("#ajax_design_btn_add").click(function(){
		loadURL("ajax-design!input.action",$('#content'));
	});

	function fn_design_read(id){
		loadURL("ajax-design!read.action?keyId="+id,$('#content'));
	}
	$("#ajax_design_btn_all").unbind("click").bind("click",function(){
		$("input#keyId").val("");
		$("#ajax_design_table").jqGrid('setGridParam',{url:'ajax-design!list.action'}).trigger("reloadGrid");
	});
</script>
